Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Detect COMPOSER_ROOT_VERSION on push events #23

Conversation

emteknetnz
Copy link
Member

Issue #11

Push events to forked repos are causing COMPOSER_ROOT_VERSION to be something like dev-pulls/1.10/module-standards, instead of 1.10

This causes issues if the module being tested is included as part of composer requiring silverstripe/installer

example

- silverstripe/recipe-cms 4.10.x-dev requires silverstripe/versioned-admin 1.10.x-dev -> satisfiable by silverstripe/versioned-admin[1.10.x-dev] from composer repo (https://repo.packagist.org/) but silverstripe/versioned-admin is the root package and cannot be modified.

This PR makes a go at better detection of COMPOSER_ROOT VERSION

The regex can be manually validated with

for V in \
    4 \
    4.10 \
    4.10.1 \
    burger \
    pulls/4/abc \
    pulls/4.10/abc \
    pulls/4.10.1/abc \
    pulls/burger/abc \
;do
    BRANCH_OR_TAG=$V
    if [[ $BRANCH_OR_TAG =~ ^([1-9]+)$ ]] || \
        [[ $BRANCH_OR_TAG =~ ^([0-9]+\.[0-9]+)$ ]] || \
        [[ $BRANCH_OR_TAG =~ ^pulls/([1-9]+)/.+$ ]] || \
        [[ $BRANCH_OR_TAG =~ ^pulls/([0-9]+\.[0-9]+)/.+$ ]]; \
    then
        COMPOSER_ROOT_VERSION="${BASH_REMATCH[1]}.x-dev"
    elif [[ $BRANCH_OR_TAG =~ ^[0-9]\.[0-9]+\.[0-9]+ ]]; then
        COMPOSER_ROOT_VERSION="${BRANCH_OR_TAG}"
    else
        COMPOSER_ROOT_VERSION="dev-${BRANCH_OR_TAG}"
    fi
    echo $COMPOSER_ROOT_VERSION
done

@emteknetnz emteknetnz changed the title FIX Handle pulls/4/mybranch style branches FIX Detect COMPOSER_ROOT_VERSION on push events Jul 1, 2022
@emteknetnz emteknetnz force-pushed the pulls/1.1/composer-root-version branch from 5d385c3 to 52453cd Compare July 1, 2022 00:34
@emteknetnz emteknetnz force-pushed the pulls/1.1/composer-root-version branch from 52453cd to e56b19e Compare July 1, 2022 00:34
@emteknetnz emteknetnz mentioned this pull request Jul 1, 2022
40 tasks
Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pulls/4.10.1/abc gets evaluated as dev-pulls/4.10.1/abc - should it be evaluated as 4.10.1 instead?
dev-pulls/4.10.1/abc definitely won't exist as something composer is aware of (unless the pulls branch was made on the original repo instead of a fork, but that's not the situation we're trying to catch here)
burger is getting evaluated as dev-burger - but it should be falling back to the git history logic instead.

Wait nevermind. I see that the else statement in your test logic in the description would ultimately be where the git fallback logic goes anyway.

.github/workflows/ci.yml Show resolved Hide resolved
@GuySartorelli GuySartorelli merged commit 4b2710c into silverstripe:1.1 Jul 1, 2022
@GuySartorelli GuySartorelli deleted the pulls/1.1/composer-root-version branch July 1, 2022 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants